package com.file.manage.infrastructure.dao.impl;


import cn.hutool.core.collection.CollUtil;
import com.file.manage.domain.entity.FolderStencil;
import com.file.manage.infrastructure.base.dao.impl.BaseDaoImpl;
import com.file.manage.infrastructure.dao.FolderStencilDao;
import com.file.manage.infrastructure.mapper.FolderStencilMapper;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author H41
 * @Type FolderStencilDaoImpl.java
 * @date 2025/6/1 1:15
 * @Desc
 */
@Repository
public class FolderStencilDaoImpl extends BaseDaoImpl<FolderStencilMapper, FolderStencil> implements FolderStencilDao {
    @Override
    public ListMultimap<Integer, String> prentLevel2FolderStencilMap() {
        List<FolderStencil> list = this.list();
        ListMultimap<Integer, String> multimap = ArrayListMultimap.create();
        if (CollUtil.isNotEmpty(list)) {
            list.forEach(folderStencil -> multimap.put(folderStencil.getParentLevel(), folderStencil.getName()));
        }
        return multimap;
    }
}
